import java.util.Arrays;

public class MaoPao {
    public static void main(String[] args) {
        int[] arr={1,2,8,4,9,8,7,6,5};
        boolean flag=false;
        for (int i = 1; i < arr.length; i++) {
            for (int j=0;j<arr.length-i;j++){
                flag=false;
                if (arr[j]>arr[j+1]){
                    int temp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }else flag=true;
            }
            if (flag){
                System.out.println("结束了");
                break;

            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
